package com.blog.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.blog.dao.BlogMapper;
import com.blog.entity.Blog;

@Transactional
@Service
public class BlogServiceImpl implements BlogService {

	@Autowired BlogMapper blogMapper;
	
	@Override
	public Integer createBlog(Blog blog) {
		int res = blogMapper.createBlog(blog);
		return res;
	}

	@Override
	public List<Map<String, Object>> getBolgs(Map<String,Object> map) {
		List<Map<String, Object>> blogs = new ArrayList<>();
		blogs = blogMapper.getBolgs(map);
		return blogs;
	}

	@Override
	public Blog getBolg(int blogId) {
		Blog blog = blogMapper.getBolg(blogId);
		return blog;
	}

	@Override
	public Integer saveBlog(Blog blog) {
		int res = blogMapper.saveBlog(blog);
		return res;
	}

	@Override
	public Integer delBlog(int blogId) {
		int res = blogMapper.delBlog(blogId);
		return res;
	}

	@Override
	public Set<String> selectTags(String userName) {
		Set<String> tags = blogMapper.selectTags(userName);
		return tags;
	}

	@Override
	public Integer getTagTotal(Map<String,String> map) {
		Integer resMap = blogMapper.getTagTotal(map);
		return resMap;
	}

	@Override
	public String getAllBlogTotal(String userName) {
		String total = blogMapper.getAllBlogTotal(userName);
		return total;
	}

	@Override
	public String getTagTotalByUserNameAndTag(Map<String, String> map) {
		String res = blogMapper.getTagTotalByUserNameAndTag(map);
		return res;
	}

}
